package com.woniu.stafforder.controller;

import com.woniu.common.util.ResponseData;
import com.woniu.stafforder.dto.ExpressDto;
import com.woniu.stafforder.service.OrderExpressSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 物流下单发货
 */
@RestController
public class ExpressSendController {
    @Autowired
    private OrderExpressSendService orderExpressSendService;

    /**
     * 根据主订单生成多个子订单物流
     * @param orderNum
     * @return
     */
    @PostMapping("/payAddExpress/{orderNum}")
    public ResponseData<?> addExpress(@PathVariable("orderNum") Long orderNum) {
        return orderExpressSendService.addExpress(orderNum);
    }

    /**
     * 查询物流
     * @param orderNum
     * @return
     */
    @GetMapping("/queryExpress/{orderNum}")
    public ResponseData<?> queryExpress(@PathVariable("orderNum") Long orderNum) {
        return orderExpressSendService.queryExpress(orderNum);
    }

    /**
     * 添加物流起点到终点经纬度
     * @param expressDto 接子订单id和轨迹数组
     * @return
     */
    @PostMapping("/addExpressPoint")
    public ResponseData<?> addExpressPoint(@RequestBody ExpressDto expressDto){
        return orderExpressSendService.addExpressPoint(expressDto);
    }

    /**
     * 获取快递当前经纬度
     * @param expressCode 快递码
     * @return
     */
    @GetMapping("/getExpressPoint/{expressCode}")
    public ResponseData<?> getExpressPoint(@PathVariable("expressCode") String expressCode){
        return orderExpressSendService.getExpressPoint(expressCode);
    }
}